package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	_ "time"
)

var Channerl chan int
var Number int
var jiShu int

func main() {
	Channerl = make(chan int)
	fmt.Println(Channerl)
	fmt.Println("请输入数字")
	reader := bufio.NewReader(os.Stdin)
	for {
		data, _, _ := reader.ReadLine()
		number, err := strconv.Atoi(string(data))
		if err != nil {
			fmt.Println("请输入正常数字")
		} else {
			Number = number
			break
		}
	}
	fmt.Printf("需要打印%d次\n", Number)
	MyGo(Number)
	<-Channerl
	fmt.Println("结束了啊")
}
func MyGo(number int) {
	for i := 0; i < number; i++ {
		go GoOne(i)
	}
}

func GoOne(number int) {
	n := number * number
	go GoPrint(n)
}

func GoPrint(number int) {

	fmt.Printf("结果为：%d\n", number)

	jiShu++
	if jiShu == Number {
		Channerl <- 10
	}

}
